﻿@using Dignite.Abp.DynamicForms.Switch
@inherits FormControlComponentBase<SwitchFormControl,SwitchConfiguration,bool>

<Field>
    <FieldLabel>@Field.DisplayName</FieldLabel>
    <FieldBody>      
        <Switch TValue="bool" Checked="@Checked(Field.Value)" CheckedChanged="@ChangeValueAsync"></Switch>
        <FieldHelp>@Field.Description</FieldHelp>
    </FieldBody>
</Field>


@code{
    private bool Checked(object value)
    {
        if (value == null)
            return false;
        else
        {
            bool defaultChecked = false;
            bool.TryParse(value.ToString(), out defaultChecked);
            return defaultChecked;
        }
    }
}